﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sylvain.Manager;
using Sylvain.Model;

public partial class CurrentContracts : System.Web.UI.Page
{
    /// <summary>
    /// Display content of the Page.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ISylvainManager objManager = new SylvainManager();
            int pageId = objManager.GetPageId("current_contracts");
            string pageContent = objManager.GetPageContent(pageId);
            if (pageContent.Length > 0)
            {

                mainDiv.InnerHtml = pageContent;
            }
            //Get list of all Contracts and Bind with Datalist
            List<Contract> listContracts = new List<Contract>();
            listContracts = objManager.GetAllContracts();
            dlCurrentContracts.DataSource = listContracts;
            dlCurrentContracts.DataBind();

        }
    }

    /// <summary>
    /// Get Contract Description for Particular Contract Id.
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void dlCurrentContracts_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "CurrentContracts")
        {
            int id = Convert.ToInt32(e.CommandArgument);
            Contract objContract = new Contract();
            ISylvainManager objManager = new SylvainManager();
            objContract = objManager.GetContractDescription(id);
            mainDiv.Visible = false;
            divTitle.Visible = true;
            imgContract.Visible = true;
            divDescription.Visible = true;
            divTitle.InnerHtml = "<span style='font-size:14px; font-weight:bold; color:#494848; padding-left:5px;'>" + objContract.ClientName + "</span>";
            divDescription.InnerHtml = "<p>" + objContract.Description + "</p>";
            imgContract.ImageUrl = "~/Admin/AdminImages/" +objContract.Image;
        }
    }
    /// <summary>
    /// Display Page Content for GSA Schedule
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkGSASchedule_Click(object sender, EventArgs e)
    {
        ISylvainManager objManager = new SylvainManager();
        int pageId = objManager.GetPageId("gsa_schedule");
        string pageContent = objManager.GetPageContent(pageId);
        if (pageContent.Length > 0)
        {
            mainDiv.Visible = true;
            divTitle.Visible = false;
            imgContract.Visible = false;
            divDescription.Visible = false;
            mainDiv.InnerHtml = pageContent;
        }

    }
    /// <summary>
    /// Display Page Content for Past And Current Clients
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkPastAndCurrentClients_Click(object sender, EventArgs e)
    {

        ISylvainManager objManager = new SylvainManager();
        int pageId = objManager.GetPageId("past_and_current_clients");
        string pageContent = objManager.GetPageContent(pageId);
        if (pageContent.Length > 0)
        {
            mainDiv.Visible = true;
            divTitle.Visible = false;
            imgContract.Visible = false;
            divDescription.Visible = false;
            mainDiv.InnerHtml = pageContent;
        }

    }
}
          
       